import { request } from '@umijs/max';

// 获取接口列表
export async function resourcepage(params: any) {
  return request('/api/sys/resource/page', {
    method: 'GET',
    params,
  });
}

// 新增接口
export async function resourceAdd(data: any) {
  return request('/api/sys/resource/add', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json' // 确保发送JSON格式的数据
    },
    data,
  });
}

// 更新接口
export async function resourceUpdate(data: any) {
  return request('/api/sys/resource/update', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json' // 确保发送JSON格式的数据
    },
    data,
  });
}

// 删除接口
export async function resourceDelete(params) {
  return request('/api/sys/resource/delete', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json' // 确保发送JSON格式的数据
    },
    data: params // 直接发送params对象，不需要手动字符串化
  });
}

// 获取详情
export async function resourceDetail(params: any) {
  return request('/api/sys/resource/detail', {
    method: 'GET',
    params,
  });
}
// 获取资源树
export async function resourceListTree() {
  return request('/api/sys/resource/listTree', {
    method: 'GET',
  });
}
